/**
 * 首页 实验室首页
 */
<template>
    <div>
      <!-- 面包屑导航 -->
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>我的实验室</el-breadcrumb-item>
      </el-breadcrumb>
      <div class= "word" style="margin-bottom: 20px;">
        <div style="font-size: 20px; margin-bottom: 20px;">关于实验室 |</div>
        <div style="font-size: 10px;">
          {{datainfo.detail}}
        </div>
      </div>
      <div>
        <img style="width: 100%; height: 100%;" :src="url" alt="">
      </div>
      <div style="margin-bottom: 20px;">
        <div style="font-size: 20px; margin-bottom: 20px;">更多链接 |</div>
        <el-link href="https://element.eleme.io" target="_blank">默认链接</el-link> |
        <el-link type="primary">主要链接</el-link> |
        <el-link type="success">成功链接</el-link> |
        <el-link type="warning">警告链接</el-link> |
        <el-link type="danger">危险链接</el-link> |
        <el-link type="info">信息链接</el-link>
      </div>
    </div>
</template>
<script type="text/ecmascript-6">
import { getLaboratoryInfo } from '../../api/shiyanshi'
export default {
  data() {
    return {
      datainfo:{},
      url:""
    }
  },
  created(){
    
  },
  mounted(){
    this.getDataInfo()
  },
  methods:{
    getFileNameFromPath(path) {  
      const lastIndex = path.lastIndexOf('\\'); // 找到最后一个反斜杠的位置  
      if (lastIndex !== -1) {  
          return path.substr(lastIndex + 1); // 返回最后一个反斜杠后面的所有内容  
      } else {  
          // 如果没有找到反斜杠，整个字符串可能就是文件名  
          return path;  
      }  
    },
    getDataInfo(){
      let param = {};
      let _this = this;
      param.id = sessionStorage.getItem("mainId");
      getLaboratoryInfo(param).then(res =>{
        if(res.status == 200){
          this.datainfo = res.data
          sessionStorage.setItem("title",this.datainfo.name);
          if(this.datainfo.imgList && this.datainfo.imgList.length > 0){
            _this.url = this.getFileNameFromPath(_this.datainfo.imgList[0].img);
            _this.url = "http://localhost:18088/file/" + _this.url
            console.log("图片地址",_this.url)
          }
        }
      });
    }
  }
}
</script>
<style>
  .word {
        position: absolute;
        left: 200;
        top: 100px;
        width: 275px;
        height: 265px;
        box-sizing: border-box;
        padding: 10px;
        color:white;
    }
</style>